//
//  WJDataManager.h
//  WJBSApp
//
//  Created by dllo on 16/7/25.
//  Copyright © 2016年 王景伟. All rights reserved.
//
// 写添加关注 删除关注的方法

#import <Foundation/Foundation.h>
#import "WJPublishModel.h"
#import "WJLastModel.h"

@interface WJDataManager : NSObject

// 创建数据库
+ (instancetype)shareFMDB;

// 打开数据库
- (void)openDB;

// 创建收藏的表
- (void)createFollowTable;

// 增
- (void)insertWithID:(NSString *)userID username:(NSString *)username tiezi_count:(NSInteger)tiezi_count follow_count:(NSString *)follow_count profile_image:(NSString *)profile_image;

// 删
- (void)deleteWith:(NSString *)userID;

// 查
- (NSMutableArray *)selectAll;

// 判断是否拥有  用来界面显示
- (BOOL)isExistUserID:(NSString *)userID;




#pragma mark - 第一个分区的东西  +进去的

// 创建订阅的表
- (void)createFirTable;

// 增 订阅
- (void)insertToFirTheme_id:(NSInteger)theme_id Image_list:(NSString *)image_list Sub_number:(NSInteger)sub_number Post_num:(NSInteger)post_num Theme_name:(NSString *)theme_name;

// 删 订阅
- (void)deleteFromFirWithTheme_id:(NSInteger)theme_id;

// 查 订阅
- (NSMutableArray *)selectAllFir;

// 判断是否拥有  用来界面显示
- (BOOL)isExistTheme_id:(NSInteger)Theme_id;






#pragma mark - 第二个分区的东西

// 创建订阅的表
- (void)createSecTable;

// 增 订阅
- (void)insertToSecTheme_id:(NSInteger)theme_id Image_list:(NSString *)image_list Sub_number:(NSInteger)sub_number Post_num:(NSInteger)post_num Theme_name:(NSString *)theme_name;

// 删 订阅
- (void)deleteFromSecTheme_id:(NSInteger)theme_id;

// 查 订阅
- (NSMutableArray *)selectAllSec;
// 查询是否拥有
- (BOOL)isExistSecTheme_id:(NSInteger)Theme_id;



// *********************发表的数据库***********************
- (void)createPublishTable;

// 增
- (void)insertModel:(WJPublishModel *)model;

// 删(根据描述删除)
- (void)deleteFromText:(NSString *)nowTime;

// 查
- (NSMutableArray *)selectAllPublish;


// **********************判断图片有没有************************
- (void)createPicTable;

// 增
- (void)insertPicName:(NSString *)picName;

// 查
- (NSMutableArray *)selectAllPic;

// 是否拥有
- (BOOL)isExistPicName:(NSString *)picName;

// 删除所有
- (void)deleteAllPic;

























//// *********************段子***********************
//- (void)createPublishTable;
//
//// 增
//- (void)insertType:(NSString *)type text:(NSString *)text;
//
//// 删
//- (void)deleteFromText:(NSString *)text;
//
//// 查
//- (NSMutableArray *)selectAllText;



//// *********************链接***********************
//- (void)createPublishLinksTable;
//
//// 增
//- (void)insertType:(NSString *)type links:(NSString *)links text:(NSString *)text;
//
//// 删
//- (void)deleteFromLinks:(NSString *)Links;
//
//// 查
//- (NSMutableArray *)selectAllLinks;
//
//
//// *********************图片***********************
//- (void)createPublishPicTable;
//
//// 增
//- (void)insertType:(NSString *)type pic:(NSString *)links text:(NSString *)text;
//
//// 删
//- (void)deleteFromPicText:(NSString *)text;
//
//// 查
//- (NSMutableArray *)selectAllPic;


// 发视屏
// 发声音
















































































@end
//// 这是创建文件里面的表格
//- (void)createFollowTable
//{
//    NSString *sqlStr  = @"create table if not exists follow (userID text primary key ,name text,tiezi_count text,comment_count text,profile_image text,fans_count text) ";
//    
//    [self executeSqlWithStr:sqlStr showLog:@"CREATE FOllOW TABLE"];
//}
//
////增 (由于主键只有一个增加相同的内容必然失败) 所以这个可以用来判断这里是否拥有
//- (void)insertSearch:(WJSearchModel *)model
//{
//    NSString *sqlStr =[NSString stringWithFormat:@"insert into follow (userID,name,tiezi_count,comment_count,profile_image,fans_count) values ('%@','%@','%@','%@','%@','%@')",model.id,model.username,model.tiezi_count,model.comment_count,model.profile_image,model.fans_count];
//    
//    [self executeSqlWithStr:sqlStr showLog:@"INSERT "];
//}
//
////删
//- (void)deleteWith:(NSString *)userID
//{
//    NSString *sqlStr = [NSString stringWithFormat:@"delete from follow where userID = '%@' ",userID];
//    
//    [self executeSqlWithStr:sqlStr showLog:@"DELETE FOLLOW"];
//}
//
//
////查
//- (NSMutableArray *)selectAll
//{
//    NSMutableArray *array = [NSMutableArray array];
//    
//    NSString *sql = [NSString stringWithFormat:@"select *from follow"];
//    //执行查询语句
//    FMResultSet *set = [self.fmdb executeQuery:sql];
//    //FMResultSet 是用来遍历表中符合要求的每一行
//    while ([set next]) {
//        NSString *set_userID = [set objectForColumnName:@"userID"];
//        NSString *set_name = [set objectForColumnName:@"name"];
//        NSString *set_tiezi_count = [set objectForColumnName:@"tiezi_count"];
//        NSString *set_comment_count = [set objectForColumnName:@"comment_count"];
//        NSString *set_profile_image = [set objectForColumnName:@"profile_image"];
//        NSString *set_fans_count = [set objectForColumnName:@"fans_count"];
//        
//        WJSearchModel *model = [[WJSearchModel alloc]init];
//        model.id = set_userID;
//        model.username = set_name;
//        model.tiezi_count = set_tiezi_count;
//        model.comment_count = set_comment_count;
//        model.profile_image = set_profile_image;
//        model.fans_count = set_fans_count;
//        [array addObject:model];
//    }
//    
//    return array;
//}
//
//- (BOOL)isExistUserID:(NSString *)userID
//{
//    NSMutableArray *array = [self selectAll];
//    
//    for (WJSearchModel *model in array) {
//        
//        if ([model.id isEqualToString:userID]) {
//            return YES;
//        }
//    }
//    
//    return NO;
//}
